<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="js/vue.js"></script>
</head>
<body>
    <div id="app">
            <h3>数字为{{num}}</h3>
            <h3>姓名{{username}}</h3>
            <button @click="add">加法</button>
            <button @click="reduce">减法</button>
    </div>
    
</body>
<script>
    //数据驱动  没有了大量的dom操作  他的dom全部放到内存中  虚拟DOM
    //mvvm框架   model-view -view-model
    //声明式渲染
    //渐进式框架
    new  Vue({
        el:"#app",//表示vue的渲染范围
        data:{//表示数据
            num:100,//在页面中 {{里面放变量}}
            username:"leson",
        },
        methods:{//方法
               add:function(){
                //    console.log(this);
                this.$data.num = this.$data.num+1;
               },
               reduce(){
                   this.num = this.num-2;
               }
        }
    });




</script>
</html>